from celery import Celery, signals

from app.core.config import settings
from app.tasks.celery_base import make_celery
from app.utils.av_util import add_watermark
from app.utils.oss_util import OSSUtil

app = make_celery()





# 添加水印
@app.task(name="watermark")
def watermark(input_video, watermark_image, position=(10, 10)):
    print("开始处理数据")
    """
    处理数据
    """
    output_video = add_watermark(input_video, watermark_image, position)

    client = OSSUtil(settings.ALIYUN_OSS_ENDPOINT, settings.ALIYUN_OSS_ACCESS_KEY_ID,
                     settings.ALIYUN_OSS_ACCESS_KEY_SECRET, settings.ALIYUN_OSS_BUCKET_NAME, settings.ALIYUN_OSS_REGION)
    object_name = client.upload_file(output_video)
    return client.get_signed_url(object_name)
